package com.gitee.dupe.log.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.gitee.dolt.annotation.injection.InjectionField;
import com.gitee.dolt.core.base.entity.SuperEntity;
import com.gitee.dolt.core.constant.InjectionFieldConstants;
import com.gitee.dolt.model.RemoteData;
import com.gitee.dolt.utils.NumberUtils;
import com.gitee.dupe.common.dto.UserGeneralDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;

/**
 * <p>
 *
 * </p>
 *
 * @author LYH
 * @since 2020-06-30
 */
@Data
@Accessors(chain = true)
@TableName("b_opt_log")
@ApiModel(value = "OptLog", description = "系统日志")
public class OptLog extends SuperEntity<Long> {

    /**
     * 操作IP
     */
    @ApiModelProperty(value = "操作IP")
    @TableField(value = "request_ip")
    private String requestIp;

    /**
     * 日志类型
     * #LogType{OPT:操作类型;EX:异常类型}
     */
    @ApiModelProperty(value = "日志类型")
    @TableField(value = "type")
    private String type;

    /**
     * 操作人
     */
    @ApiModelProperty(value = "操作人")
    @TableField(value = "user_id")
    @InjectionField(api = InjectionFieldConstants.USER_ITEM_CLASS, method = InjectionFieldConstants.USER_ITEM_METHOD)
    private RemoteData<Long, UserGeneralDTO> userId;

    /**
     * 操作模块
     */
    @ApiModelProperty(value = "操作模块")
    @TableField(value = "opt_module")
    private String optModule;

    /**
     * 操作类型
     */
    @ApiModelProperty(value = "操作类型")
    @TableField(value = "opt_type")
    private String optType;

    /**
     * 操作描述
     */
    @ApiModelProperty(value = "操作描述")
    @TableField(value = "opt_desc")
    private String optDesc;

    /**
     * 类路径
     */
    @ApiModelProperty(value = "类路径")
    @TableField(value = "class_path")
    private String classPath;

    /**
     * 请求方法
     */
    @ApiModelProperty(value = "请求方法")
    @TableField(value = "action_method")
    private String actionMethod;

    /**
     * 请求地址
     */
    @ApiModelProperty(value = "请求地址")
    @TableField(value = "request_uri")
    private String requestUri;

    /**
     * 请求类型
     * #HttpMethod{GET:GET请求;POST:POST请求;PUT:PUT请求;DELETE:DELETE请求;PATCH:PATCH请求;TRACE:TRACE请求;HEAD:HEAD请求;OPTIONS:OPTIONS请求;}
     */
    @ApiModelProperty(value = "请求类型")
    @TableField(value = "http_method")
    private String httpMethod;

    /**
     * 请求参数
     */
    @ApiModelProperty(value = "请求参数")
    @TableField(value = "params")
    private String params;

    /**
     * 开始时间
     */
    @ApiModelProperty(value = "开始时间")
    @TableField(value = "start_time")
    private LocalDateTime startTime;

    /**
     * 完成时间
     */
    @ApiModelProperty(value = "完成时间")
    @TableField(value = "finish_time")
    private LocalDateTime finishTime;

    /**
     * 消耗时间
     */
    @ApiModelProperty(value = "消耗时间")
    @TableField(value = "consuming_time")
    private Long consumingTime;

    /**
     * 浏览器
     */
    @ApiModelProperty(value = "浏览器")
    @TableField(value = "ua")
    private String ua;

    /**
     * 业务id
     */
    @ApiModelProperty(value = "业务id")
    @TableField(value = "biz_id")
    private String bizId;

    @ApiModelProperty(value = "日志来源")
    @TableField(value = "source")
    private String source;


}
